package io.seata.sharding4.storage.controller;

import io.seata.sharding4.common.dto.CommodityDTO;
import io.seata.sharding4.common.response.ObjectResponse;
import io.seata.sharding4.storage.service.IStorageService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 前端控制器
 *
 * @author Administrator
 */
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/storage")
public class StorageController {
    private final IStorageService storageService;

    /**
     * 扣减库存
     */
    @PostMapping("dec_storage")
    ObjectResponse decreaseStorage(@RequestBody CommodityDTO commodityDTO) {
        log.info("请求库存微服务：{}", commodityDTO.toString());
        return storageService.decreaseStorage(commodityDTO);
    }
}

